<?php
/**
 * Created by PhpStorm.
 * User: W
 * Date: 2019/1/11
 * Time: 10:03
 */

namespace app\sports_admin\controller;
use app\sports_admin\model\Heart as HeartModel;
use Think\Model;
use think\Request;
use app\exception\HeartException;
class Heart extends Base
{
    //教学心得 页面
    public function index()
    {
        return view("index");
    }
    //教学心得 列表
    public function heartList()
    {
        $params = Request::instance()->only(['page','rows','sort','sortOrder','searchName']);
        $page = intval($params['page']) ? intval($params['page']) : 1;
        $rows = intval($params['rows']) ? intval($params['rows']) : 15;
        $sort = trim($params['sort']) ? trim($params['sort']) : 'id';
        $sortOrder = trim($params['sortOrder']) ? trim($params['sortOrder']) : 'asc';
        $searchName = trim($params['searchName']);
        $result = HeartModel::heartList($page,$rows,$sort,$sortOrder,$searchName);
        return json($result);
    }
    //教学心得 详细信息
    public function detail()
    {
        $data = HeartModel::detail();
        return view("detail",compact("data"));
    }
    //教学心得 变更状态
    public function updateHeart(Request $request)
    {
        if($request->isAjax()){
            return $data = HeartModel::updateHeart();
        }
    }
    //教学心得 删除心得
    public function delHeart(Request $request)
    {
        if($request->isAjax()){
            return $data = HeartModel::delHeart();
        }

    }

}